Technical details
library(GeoPressureR)
library(leaflet)
library(leaflet.extras)
library(raster)
library(dplyr)
library(ggplot2)
library(kableExtra)
library(plotly)
library(GeoLocTools)
setupGeolocation()
knitr::opts_chunk$set(echo = FALSE)
load(paste0("../data/1_pressure/", params$gdl_id, "_pressure_prob.Rdata"))
load(paste0("../data/2_light/", params$gdl_id, "_light_prob.Rdata"))
load(paste0("../data/3_static/", params$gdl_id, "_static_prob.Rdata"))
load(paste0("../data/4_basic_graph/", params$gdl_id, "_basic_graph.Rdata"))
load(paste0("../data/5_wind_graph/", params$gdl_id, "_wind_graph.Rdata"))
col <- rep(RColorBrewer::brewer.pal(8, "Dark2"), times = ceiling(max(pam$sta$sta_id) / 8))
All the results produced here are generated with (1) the raw geolocator data, (2) the labeled files of pressure and light and (3) the parameters listed below.
kable(gpr) %>% scroll_box(width = "100%")
| gdl_id | keep | crop_start | crop_end | thr_dur | extent_N | extent_W | extent_S | extent_E | map_scale | map_max_sample | map_margin | prob_map_s | prob_map_s_calib | prob_map_thr | shift_k | kernel_adjust | calib_lon | calib_lat | calib_1_start | calib_1_end | calib_2_start | calib_2_end | calib_2_lon | calib_2_lat | prob_light_w | thr_prob_percentile | thr_gs | thr_as | RingNo | scientific_name | common_name | mass | wing_span | Color | sta_id_winter |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 24IS | 1 | 2019-08-01 | 2019-10-16 15:35:00 | 0 | 51 | -18 | 5 | 16 | 4 | 300 | 30 | 1 | 1.3 | 0.9 | 0 | 1.4 | 8.692212 | 46.55493 | 2019-08-01 | 2019-09-16 | NA | NA | NA | NA | 0.09 | 0.95 | 120 | 100 | N588304 | Oenanthe oenanthe | Northern wheatear | NA | NA | #FECB52 | NA |
The labeling of pressure data is illustrated with this figure. The black dots indicates the pressure datapoint not considered in the matching. Each stationary period is illustrated by a different colored line.
pressure_na <- pam$pressure %>%
mutate(obs = ifelse(isoutlier | sta_id == 0, NA, obs))
p <- ggplot() +
geom_line(data = pam$pressure, aes(x = date, y = obs), colour = "grey") +
# geom_point(data = subset(pam$pressure, isoutlier), aes(x = date, y = obs), colour = "black") +
# geom_line(data = pressure_na, aes(x = date, y = obs, color = factor(sta_id)), size = 0.5) +
geom_line(data = do.call("rbind", shortest_path_timeserie) %>% filter(sta_id > 0), aes(x = date, y = pressure0, col = factor(sta_id))) +
theme_bw() +
scale_colour_manual(values = col) +
scale_y_continuous(name = "Pressure(hPa)")
ggplotly(p, dynamicTicks = T) %>% layout(showlegend = F)
pressure_ts_bind <- do.call("rbind", shortest_path_timeserie) %>%
filter(!is.na(sta_id))
pam$pressure %>%
left_join(pressure_ts_bind %>% dplyr::select(c("date", "pressure0")), by = "date") %>%
mutate(diff = ifelse(is.na(pressure0), 0, obs - pressure0)) %>%
filter(sta_id > 0 & !isoutlier) %>%
group_by(sta_id) %>%
mutate(sta_id = paste0(sta_id, " (SD=", round(sd(diff), 2), " ; N=", n(), ")")) %>%
ggplot(aes(x = diff)) +
geom_histogram(aes(y = (..count..) / tapply(..count.., ..PANEL.., sum)[..PANEL..]), binwidth = .2) +
facet_wrap(~sta_id) +
scale_x_continuous(name = "Pressure Geolocator - best match ERA5 (hPa)") +
scale_y_continuous(name = "Normalized histogram")
raw_geolight <- pam$light %>%
transmute(
Date = date,
Light = obs
)
lightImage(tagdata = raw_geolight, offset = 0)
tsimagePoints(twl$twilight,
offset = 0, pch = 16, cex = 1.2,
col = ifelse(twl$deleted, "grey20", ifelse(twl$rise, "firebrick", "cornflowerblue"))
)
abline(v = gpr$calib_2_start, lty = 1, col = "firebrick", lwd = 1.5)
abline(v = gpr$calib_1_start, lty = 1, col = "firebrick", lwd = 1.5)
abline(v = gpr$calib_2_end, lty = 2, col = "firebrick", lwd = 1.5)
abline(v = gpr$calib_1_end, lty = 2, col = "firebrick", lwd = 1.5)
The probability map resulting from light data alone can be seen below.
li_s <- list()
l <- leaflet(width = "100%") %>%
addProviderTiles(providers$Stamen.TerrainBackground) %>%
addFullscreenControl()
for (i_r in seq_len(length(light_prob))) {
i_s <- metadata(light_prob[[i_r]])$sta_id
info <- pam$sta[pam$sta$sta_id == i_s, ]
info_str <- paste0(i_s, " | ", info$start, "->", info$end)
li_s <- append(li_s, info_str)
l <- l %>% addRasterImage(light_prob[[i_r]], opacity = 0.8, colors = "OrRd", group = info_str)
}
l %>%
addCircles(lng = gpr$calib_lon, lat = gpr$calib_lat, color = "black", opacity = 1) %>%
addLayersControl(
overlayGroups = li_s,
options = layersControlOptions(collapsed = FALSE)
) %>%
hideGroup(tail(li_s, length(li_s) - 1))
We can compare light and pressure location at long stationary stopover (>5 days). By assuming the best match of the pressure to be the truth, we can plot the histogram of the zenith angle and compare to the fit of kernel density at the calibration site.
raw_geolight <- pam$light %>%
transmute(
Date = date,
Light = obs
)
dur <- unlist(lapply(pressure_prob, function(x) difftime(metadata(x)$temporal_extent[2],metadata(x)$temporal_extent[1], units = "days" )))
long_id <- which(dur>5)
par(mfrow = c(2, 3))
for (i_s in long_id){
twl_fl <- twl %>%
filter(!deleted) %>%
filter(twilight>shortest_path_timeserie[[i_s]]$date[1] & twilight<tail(shortest_path_timeserie[[i_s]]$date,1))
sun <- solar(twl_fl$twilight)
z_i <- refracted(zenith(sun, shortest_path_timeserie[[i_s]]$lon[1], shortest_path_timeserie[[i_s]]$lat[1]))
hist(z_i, freq = F, main = paste0("sta_id=",i_s, " | ",nrow(twl_fl),"twls"))
lines(fit_z, col = "red")
xlab("Zenith angle")
}
Similarly, we can plot the line of sunrise/sunset at the best match of pressure (yellow line) and compare to the raw and labeled light data.
lightImage(
tagdata = raw_geolight,
offset = gpr$shift_k / 60 / 60
)
tsimagePoints(twl$twilight,
offset = gpr$shift_k / 60 / 60, pch = 16, cex = 1.2,
col = ifelse(twl$deleted, "grey20", ifelse(twl$rise, "firebrick", "cornflowerblue"))
)
for (ts in shortest_path_timeserie){
twl_fl <- twl %>%
filter(twilight>ts$date[1] & twilight<tail(ts$date,1))
if (nrow(twl_fl)>0){
tsimageDeploymentLines(twl_fl$twilight,
lon = ts$lon[1], ts$lat[1],
offset = gpr$shift_k / 60 / 60, lwd = 3,col = adjustcolor("orange", alpha.f = 0.5))
}
}
| …1 | sta_id_s | sta_id_t | flight_duration | as_m | as_s | gs_m | gs_s | ws_m | ws_s | dist_m | dist_s | ws_m_support | ws_m_drift | start_flight | end_flight | sunrise | sunset | as_sp | gs_sp | ws_sp | dist_sp | ws_sp_support | ws_sp_drift | alt_min | alt_max | alt_mean | alt_med | alt_sumdabsdiff | alt_sumposdiff | gdl_id |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 0.5 | 26.97934 | 20.70084 | 25.28161 | 22.12765 | 3.872825 | 0.3869792 | 12.64081 | 11.06382 | -1.4580895 | 3.587862 | 2019-08-25 02:30:00 | 2019-08-25 03:00:00 | 2019-08-25 04:03:47 | 2019-08-24 18:52:28 | 3.76797 | 0.00000 | 3.767970 | 0.00000 | NA | NA | NA | NA | NA | NA | NA | NA | 24IS |
| 2 | 2 | 3 | 8.0 | 24.06175 | 10.90840 | 23.30085 | 11.40800 | 5.377384 | 1.7083335 | 186.40679 | 91.26399 | -0.1528316 | 5.375212 | 2019-09-15 17:30:00 | 2019-09-16 01:30:00 | 2019-09-16 04:41:10 | 2019-09-15 18:08:26 | 35.55989 | 36.82306 | 3.370115 | 294.58450 | 1.395731 | 3.067509 | 1945.3098 | 4057.0632 | 2918.5213 | 2972.5831 | 6961.1029 | 3902.8739 | 24IS |
| 3 | 3 | 4 | 17.0 | 60.88216 | 11.81063 | 64.78336 | 10.50064 | 13.299945 | 1.2433756 | 1101.31716 | 178.51095 | 5.1489680 | 12.262817 | 2019-09-16 18:00:00 | 2019-09-17 11:00:00 | 2019-09-17 04:42:57 | 2019-09-16 18:08:56 | 41.35821 | 47.76389 | 13.175809 | 811.98605 | 7.793431 | 10.623765 | 112.0134 | 3930.8401 | 2371.3943 | 2571.9045 | 18479.0584 | 7842.3539 | 24IS |
| 4 | 4 | 5 | 4.0 | 38.64215 | 15.12835 | 35.97324 | 15.55860 | 8.824549 | 2.0736362 | 143.89294 | 62.23439 | -1.6855461 | 8.662078 | 2019-09-17 18:00:00 | 2019-09-17 22:00:00 | 2019-09-18 04:47:14 | 2019-09-17 17:56:38 | 33.42300 | 26.74107 | 6.857087 | 106.96427 | -6.637595 | 1.721039 | -71.3019 | 1317.0302 | 753.5315 | 985.1288 | 2299.3030 | 1597.5093 | 24IS |
| 5 | 5 | 6 | 11.5 | 36.26057 | 13.38826 | 61.85784 | 11.24755 | 28.571908 | 5.1941852 | 711.36521 | 129.34682 | 26.8997252 | 9.631134 | 2019-09-28 17:30:00 | 2019-09-29 05:00:00 | 2019-09-29 04:57:40 | 2019-09-28 17:42:44 | 35.21635 | 69.94260 | 34.925974 | 804.33989 | 34.825699 | 2.644687 | 360.5464 | 4474.7615 | 2898.8228 | 3167.9335 | 7725.5414 | 3591.4569 | 24IS |
| 6 | 6 | 7 | 11.5 | 42.13209 | 16.37642 | 65.40593 | 20.22555 | 29.409624 | 6.5787717 | 752.16821 | 232.59382 | 25.7449787 | 14.216963 | 2019-09-29 18:00:00 | 2019-09-30 05:30:00 | 2019-09-30 05:16:09 | 2019-09-29 17:41:45 | 35.85819 | 69.83221 | 37.321774 | 803.07042 | 35.682977 | 10.938007 | 442.4284 | 3101.9670 | 1771.6879 | 1634.1970 | 6755.6640 | 3404.0059 | 24IS |
| 7 | 7 | 8 | 9.5 | 46.13981 | 18.25180 | 47.00935 | 23.40254 | 23.580246 | 4.0147324 | 446.58881 | 222.32410 | 6.7755117 | 22.585846 | 2019-09-30 18:00:00 | 2019-10-01 03:30:00 | 2019-10-01 05:16:13 | 2019-09-30 17:58:41 | 34.68052 | 40.79118 | 23.483493 | 387.51620 | 12.412683 | 19.934888 | 460.3193 | 3901.7128 | 2278.8710 | 2233.9543 | 10032.7554 | 5074.1485 | 24IS |
| 8 | 8 | 9 | 8.5 | 48.60386 | 16.35063 | 54.62970 | 16.98596 | 11.795870 | 4.0714654 | 464.35244 | 144.38066 | 6.9670057 | 9.518581 | 2019-10-02 18:30:00 | 2019-10-03 03:00:00 | 2019-10-03 05:16:14 | 2019-10-02 17:57:10 | 28.48829 | 35.80842 | 14.851577 | 304.37155 | 9.651771 | 11.287722 | 320.3994 | 3688.1971 | 2378.6247 | 3051.3260 | 8186.7076 | 3977.7571 | 24IS |
| 9 | 9 | 10 | 1.5 | 33.40691 | 15.18007 | 34.86053 | 17.60808 | 9.408509 | 4.9004958 | 52.29079 | 26.41213 | 2.6929379 | 9.014884 | 2019-10-03 20:30:00 | 2019-10-03 22:00:00 | 2019-10-04 05:15:19 | 2019-10-03 17:56:47 | 22.30497 | 25.62825 | 5.013362 | 38.44238 | 3.598161 | 3.490994 | 294.6068 | 930.0938 | 614.4769 | 616.6036 | 1252.6851 | 617.1981 | 24IS |
| 10 | 10 | 11 | 8.0 | 35.46366 | 12.45806 | 30.36570 | 12.54619 | 6.338948 | 2.4670974 | 242.92564 | 100.36953 | -4.8642478 | 4.064647 | 2019-10-05 19:00:00 | 2019-10-06 03:00:00 | 2019-10-06 05:13:12 | 2019-10-05 17:54:19 | 27.47179 | 21.80332 | 5.755258 | 174.42652 | -5.645741 | 1.117411 | 240.9499 | 1549.1065 | 682.7247 | 483.1351 | 5293.5327 | 2619.1217 | 24IS |
| 11 | 11 | 12 | 2.5 | 32.09210 | 13.01918 | 33.04650 | 16.77051 | 17.504190 | 2.8917670 | 82.61625 | 41.92626 | 5.5764611 | 16.592159 | 2019-10-11 21:30:00 | 2019-10-12 00:00:00 | 2019-10-12 05:12:53 | 2019-10-11 17:48:38 | 23.95550 | 10.76127 | 14.695549 | 26.90318 | -11.248766 | 9.456449 | 245.4333 | 1841.4994 | 840.7139 | 593.9665 | 3140.1573 | 1619.7243 | 24IS |
| 12 | 12 | 13 | 0.5 | 32.30848 | 22.90317 | 29.60268 | 28.98870 | 9.606418 | 2.3961741 | 14.80134 | 14.49435 | -1.2707680 | 9.521996 | 2019-10-12 21:00:00 | 2019-10-12 21:30:00 | 2019-10-13 05:13:01 | 2019-10-12 17:47:00 | 10.55381 | 0.00000 | 10.553810 | 0.00000 | NA | NA | 301.3149 | 742.4831 | 521.8990 | 521.8990 | 441.1682 | 441.1682 | 24IS |
| 13 | 13 | 14 | 3.0 | 31.99630 | 16.70220 | 32.55915 | 17.50869 | 13.754486 | 4.5048008 | 97.67744 | 52.52607 | 3.4632509 | 13.311340 | 2019-10-13 23:30:00 | 2019-10-14 02:30:00 | 2019-10-14 05:15:10 | 2019-10-13 17:46:22 | 31.09907 | 17.93545 | 14.901379 | 53.80634 | -11.804025 | 9.094839 | 282.7224 | 647.0730 | 375.5769 | 327.6826 | 922.5301 | 482.1588 | 24IS |